package com.appwoo.txtws.activity;

import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import com.appwoo.android.exception.NotFoundNetWorkException;
import com.appwoo.android.exception.TimeOutException;
import com.appwoo.txtws.app.AppActivity;
import com.appwoo.txtws.bean.MessageBean;
import com.appwoo.txtws.bean.StateBean;
import com.appwoo.txtws.bean.WebSoftSingleBean;
import com.appwoo.txtws.component.ImageZoomView;
import com.appwoo.txtws.component.Logger;
import com.appwoo.txtws.component.RqSP;
import com.appwoo.txtws.component.SimpleZoomListener;
import com.appwoo.txtws.component.ZoomState;
import com.appwoo.txtws.service.WebLimitService;
import com.appwoo.txtws.service.WebService;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import org.xmlpull.v1.XmlPullParserException;

public class RdUrlInfoActivity extends AppActivity
  implements View.OnClickListener
{
  private final int DIALOG1 = 1;
  private TextView TextView_bl;
  private TextView TextView_name;
  private TextView TextView_num;
  private TextView TextView_time;
  private TextView TextView_type;
  private String alertString;
  private String allow;
  private String equipName;
  private WebLimitService f_webLimitService = null;
  private WebService f_webService;
  private String mapUrl = "";
  private Bitmap mianMap;
  private String name;
  private String num;
  private String path;
  private String time;
  private String type;
  private String url;
  private String userId;
  private ImageZoomView v_zoomImage_big;

  private void addListener()
  {
    this.TextView_bl.setOnClickListener(this);
  }

  private String bgAddLimit()
  {
    try
    {
      String str = this.f_webLimitService.addLimitUrl(this.userId, "", this.equipName, this.url, this).getCode();
      return str;
    }
    catch (IOException localIOException)
    {
      return getString(2131427525);
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      return getString(2131427525);
    }
    catch (TimeOutException localTimeOutException)
    {
      return getString(2131427525);
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      localNotFoundNetWorkException.getClass();
    }
    return "没有连接到网络";
  }

  private String bgBigPig()
  {
    try
    {
      String str = this.mapUrl;
      int i = str.lastIndexOf('/');
      URL localURL2 = new URL(str.substring(0, i) + "/" + URLEncoder.encode(str.substring(i + 1)));
      localURL1 = localURL2;
    }
    catch (MalformedURLException localMalformedURLException)
    {
      try
      {
        while (true)
        {
          HttpURLConnection localHttpURLConnection = (HttpURLConnection)localURL1.openConnection();
          localHttpURLConnection.setReadTimeout(20000);
          localHttpURLConnection.setConnectTimeout(3000);
          localHttpURLConnection.setDoInput(true);
          localHttpURLConnection.connect();
          InputStream localInputStream = localHttpURLConnection.getInputStream();
          this.mianMap = BitmapFactory.decodeStream(localInputStream);
          localInputStream.close();
          return "";
          localMalformedURLException = localMalformedURLException;
          localMalformedURLException.printStackTrace();
          URL localURL1 = null;
        }
      }
      catch (Exception localException)
      {
      }
    }
    return getString(2131427602);
  }

  private Dialog buildDialog(Context paramContext)
  {
    AlertDialog.Builder localBuilder = new AlertDialog.Builder(paramContext);
    localBuilder.setIcon(2130837508);
    localBuilder.setTitle("是否添加到限制列表?");
    localBuilder.setPositiveButton(getString(2131427513), new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
      {
        if (RdUrlInfoActivity.this.url != null)
          new RdUrlInfoActivity.OperateLogAsyncTask(RdUrlInfoActivity.this).execute(new String[] { "add" });
      }
    });
    localBuilder.setNegativeButton(getString(2131427514), new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
      {
      }
    });
    return localBuilder.create();
  }

  private String commitBlist()
  {
    try
    {
      MessageBean localMessageBean2 = this.f_webService.blackListCommit(this.userId, this.equipName, this.url, this);
      localMessageBean1 = localMessageBean2;
      if (localMessageBean1 != null)
      {
        this.alertString = localMessageBean1.getDesc();
        return localMessageBean1.getCode();
      }
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        localIOException.printStackTrace();
        localMessageBean1 = null;
      }
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      while (true)
      {
        localXmlPullParserException.printStackTrace();
        localMessageBean1 = null;
      }
    }
    catch (TimeOutException localTimeOutException)
    {
      while (true)
      {
        localTimeOutException.printStackTrace();
        localMessageBean1 = null;
      }
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      while (true)
      {
        localNotFoundNetWorkException.printStackTrace();
        MessageBean localMessageBean1 = null;
      }
    }
    return "";
  }

  private void initActionBar()
  {
    hideBarHome();
    setBarTitle(getResources().getString(2131427832));
    setBarBackOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        RdUrlInfoActivity.this.finish();
      }
    });
  }

  private void initShowSuo()
  {
    if ((this.path != null) && (!this.path.equals("")))
    {
      String str = this.path;
      if (!str.equals(this.mapUrl))
      {
        this.mapUrl = str;
        new OperateLogAsyncTask().execute(new String[] { "pic" });
        return;
      }
      postBigMap();
      return;
    }
    this.v_zoomImage_big.setImage(null);
    this.v_zoomImage_big.setBackgroundResource(2130837774);
  }

  private void initView()
  {
    this.v_zoomImage_big = ((ImageZoomView)findViewById(2131493028));
    this.TextView_type = ((TextView)findViewById(2131493325));
    this.TextView_name = ((TextView)findViewById(2131493364));
    this.TextView_time = ((TextView)findViewById(2131493365));
    this.TextView_num = ((TextView)findViewById(2131493366));
    this.TextView_bl = ((TextView)findViewById(2131493367));
    WebSoftSingleBean localWebSoftSingleBean = WebSoftSingleBean.getInstance();
    this.type = localWebSoftSingleBean.getType();
    this.name = localWebSoftSingleBean.getName();
    this.time = localWebSoftSingleBean.getVisitedTime();
    this.num = localWebSoftSingleBean.getNum();
    this.path = localWebSoftSingleBean.getPath();
    this.url = localWebSoftSingleBean.getUrl();
    this.TextView_type.setText(this.type);
    this.TextView_name.setText(this.name);
    this.TextView_time.setText(this.time);
    this.TextView_num.setText(this.num);
    this.f_webService = new WebService();
    this.f_webLimitService = new WebLimitService();
    RqSP localRqSP = new RqSP();
    this.equipName = localRqSP.getLgDevId(this);
    this.userId = localRqSP.getLgDevAccount(this);
    initShowSuo();
  }

  private void postBigMap()
  {
    if (this.mianMap != null)
    {
      this.v_zoomImage_big.setImage(this.mianMap);
      this.v_zoomImage_big.setBackgroundColor(-1);
      ZoomState localZoomState = new ZoomState();
      this.v_zoomImage_big.setZoomState(localZoomState);
      SimpleZoomListener localSimpleZoomListener = new SimpleZoomListener();
      localSimpleZoomListener.setZoomState(localZoomState);
      this.v_zoomImage_big.setOnTouchListener(localSimpleZoomListener);
      localZoomState.setPanX(0.5F);
      localZoomState.setPanY(0.5F);
      localZoomState.setZoom(1.0F);
      localZoomState.notifyObservers();
      return;
    }
    this.v_zoomImage_big.setBackgroundResource(2130837774);
    Logger.i("TXTW", "mianMap==NULL");
  }

  public void PostShowAddInfo(String paramString)
  {
    if (paramString.equals("0"))
    {
      alertMessage(getString(2131427520));
      return;
    }
    alertMessage(getString(2131427521));
  }

  protected void backKeyCallBack()
  {
    super.backKeyCallBack();
    finish();
  }

  public void onClick(View paramView)
  {
    if (paramView == this.TextView_bl)
      showDialog(1);
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903177);
    initView();
    addListener();
    initActionBar();
  }

  protected Dialog onCreateDialog(int paramInt)
  {
    switch (paramInt)
    {
    default:
      return null;
    case 1:
    }
    return buildDialog(this);
  }

  public class OperateLogAsyncTask extends AsyncTask<String, Integer, String>
  {
    private String method = "";
    private ProgressDialog v_progressDialog;

    public OperateLogAsyncTask()
    {
    }

    protected String doInBackground(String[] paramArrayOfString)
    {
      this.method = paramArrayOfString[0];
      if (this.method.equals("pic"))
        return RdUrlInfoActivity.this.bgBigPig();
      if (this.method.equals("commit"))
        return RdUrlInfoActivity.this.commitBlist();
      if (this.method.equals("add"))
        return RdUrlInfoActivity.this.bgAddLimit();
      return "";
    }

    protected void onPostExecute(String paramString)
    {
      if (this.method.equals("pic"))
        RdUrlInfoActivity.this.postBigMap();
      while (true)
      {
        this.v_progressDialog.dismiss();
        return;
        if (this.method.equals("commit"))
        {
          if (paramString.equals("0"))
            RdUrlInfoActivity.this.alertMessage(RdUrlInfoActivity.this.getString(2131427527));
          else
            RdUrlInfoActivity.this.alertMessage(RdUrlInfoActivity.this.alertString);
        }
        else if (this.method.equals("add"))
          RdUrlInfoActivity.this.PostShowAddInfo(paramString);
      }
    }

    protected void onPreExecute()
    {
      if ((this.v_progressDialog == null) || (!this.v_progressDialog.isShowing()))
      {
        this.v_progressDialog = new ProgressDialog(RdUrlInfoActivity.this);
        this.v_progressDialog.setMessage(RdUrlInfoActivity.this.getString(2131427516));
        this.v_progressDialog.setCancelable(true);
      }
      try
      {
        this.v_progressDialog.show();
        return;
      }
      catch (Exception localException)
      {
      }
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.activity.RdUrlInfoActivity
 * JD-Core Version:    0.6.2
 */